package com.codeape.number.common.view;

import android.app.Activity;

import androidx.databinding.ObservableInt;
import androidx.viewpager.widget.ViewPager;

/**
 * 用于ViewPager的下划线指示器
 *
 * @author LiuPeiming
 * Created at 2018/10/31 16:23:12
 */
public class XPageChangeListener implements ViewPager.OnPageChangeListener {
    private Activity context;
    private ObservableInt selected;

    public XPageChangeListener( Activity context, int size, ObservableInt selected) {
        this.context = context;
        this.selected = selected;
    }

    /**
     * 页面在滑动时调用
     *
     * @param position             当前页面
     * @param positionOffset       当前页面偏移的百分比
     * @param positionOffsetPixels 当前页面偏移的像素位置
     */
    @Override
    public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {

    }

    @Override
    public void onPageSelected(int position) {
        selected.set(position);
    }

    @Override
    public void onPageScrollStateChanged(int state) {

    }
}